package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MinimumValueInTwoDimensionalArray {
	public static void main(String[] argv) {
		double[][] arr = new double[2][2];
		arr[0][0] = 34.45;
		arr[0][1] = 34.45;
		arr[1][0] = 36.67;
		arr[1][1] = 37.78;
		System.out.println("二维数组中的最小值:" + minimum(arr));
	}

	public static double minimum(double[] arr) {
		double minVal = Double.POSITIVE_INFINITY;
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] < minVal) {
				minVal = arr[i];
			}
		}
		return minVal;
	}

	public static double minimum(double[][] arr) {
		double minVal = Double.POSITIVE_INFINITY;
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] != null) {
				minVal = Math.min(minVal, minimum(arr[i]));
			}
		}
		return minVal;
	}

}
